﻿using NCS.IConnect.Core.Utilities;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Http.Controllers;

namespace NCS.IConnect.Core.WebApi.Description
{
    /// <summary>
    /// The request content specific descriptor.
    /// </summary>
    public class RequestContentDescriptor : HttpContentDescriptor
    {
        /// <summary>
        /// Gets <see cref="HttpParameterDescriptor"/>.
        /// </summary>
        /// <value>The <see cref="HttpParameterDescriptor"/>.</value>
        [JsonIgnore]
        public HttpParameterDescriptor HttpParameterDescriptor { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="RequestContentDescriptor"/> class.
        /// </summary>
        /// <param name="httpParameterDescriptor">The HTTP parameter descriptor.</param>
        /// <param name="sampleAccessor">The sample accessor.</param>
        /// <param name="supportedMediaTypes">The supported media types.</param>
        public RequestContentDescriptor(HttpParameterDescriptor httpParameterDescriptor, Func<Type, object> sampleAccessor, params string[] supportedMediaTypes) : base(httpParameterDescriptor.ParameterType, sampleAccessor, supportedMediaTypes)
        {
            Guard.ArgumentNotNull(httpParameterDescriptor, "httpParameterDescriptor");
            this.HttpParameterDescriptor = httpParameterDescriptor;
        }
    }
}